.TH lha 1
.SH NAME
lha \- compression tool for .lzh archive files.
.SH SYNOPSIS
.B lha
.RB [ - ]{ lvtxep [ q { \f[I]num\f[] }][ finv ]}[ w= < \f[I]dir\f[] >]
.I archive_file
.RI [ "file ..." ]
.SH DESCRIPTION
.PP
.B lha
is a tool for extracting .lzh archive files. It also supports variants
of the .lzh archive, such as .lzs and .pma.
.PP
This version of the lha tool is part of Lhasa, a free implementation
of the .lzh format.
.PP
.SH COMMAND SYNTAX
The lha tool has an unusual command syntax, compared to most other
Unix commands. The first parameter to the program specifies the command
to perform and all additional options. The second parameter specifies
the path to the archive file to operate on. Following this is a list
of wildcard patterns to match against the filenames of the archived
files.
.PP
The first character of the command parameter specifies the command to
perform, which is one of the following:
.TP
\fB-l\fR
List contents of the specified archive.
.TP
\fB-v\fR
Verbosely list contents of the specified archive.
.TP
\fB-t\fR
Test the integrity of the specified archive: decompress its contents and
check the CRC.
.TP
\fB-e\fR or \fB-x\fR
Extract archive. Files are extracted to the current working directory
unless the 'w' option is specified.
.TP
\fB-p\fR
Extract archive, sending decompressed files to stdout rather than
writing them to the filesystem as actual files. This is useful when used
as part of a shell pipeline.
.PP
.SH OPTIONS
The remainder of the command parameter is used to specify additional
options:
.TP
\fBq[012]\fR
Quiet mode. Higher numbers suppress more output. Level 0 is normal
operation. If no number is specified, full suppression (level 2)
is used. The quiet option also turns on the force overwrite option
('f').
.TP
\fBf\fR
Force overwrite of existing files: do not prompt.
.TP
\fBi\fR
Ignore paths of archived files: extract all archived files to the
same directory, ignoring subdirectories.
.TP
\fBn\fR
Do not perform any actual operations: instead, perform a dry run of
the requested operation and describe what would have been done on
standard output.
.TP
\fBv\fR
Verbose mode: causes extra information to be written to standard
output.
.TP
\fBw=dir\fR
Specify destination directory for extracting files. This must be
the last option of the first parameter.
.SH COMPRESSION FORMATS
The following gives some basic description of the various different supported
compression formats (as listed when using the list command documented above).
All formats are variants on the LZSS compression algorithm.
.TP
\fB\-lz4\-\fR
Uncompressed (stored) data, as used by the original LArc tool. This is not
related to the LZ4 compression algorithm of the same name.
.TP
\fB\-lz5\-\fR, \fB\-lzs\-\fR
Compression formats introduced with the original LArc tool.
\-lzs\- uses a 2KiB sliding window while \-lz5\- uses a 4KiB window.
.TP
\fB\-lhd\-\fR
Directory entry. No data is stored, only headers.
.TP
\fB\-lh0\-\fR
Uncompressed (stored) data, as used in LHarc and LHa.
.TP
\fB\-lh1\-\fR
Compression algorithm introduced with LHarc. This uses a 4KiB sliding window
with dynamic Huffman encoding.
.TP
\fB\-lh4\-\fR, \fB\-lh5\-\fR, \fB\-lh6\-\fR, \fB\-lh7\-\fR
New algorithm introduced with LHa (aka LHarc v2.0). The original versions
(\-lh4\- and \-lh5\-) used 8KiB and 16KiB sliding window sizes, respectively.
Later versions introduced new variants with larger window sizes: \-lh6\-
(64KiB) and \-lh7\- (128KiB).
.TP
\fB\-lhx\-\fR
Variant on the \-lh4\- format listed above introduced by UNLHA32.dll that
extends the window size to 1MiB.
.TP
\fB\-lk7\-\fR
Variant on the \-lh4\- format listed above that was introduced by the LHark
tool (a fork of LHa). This is actually named \-lh7\- within the archive files,
but Lhasa renames it internally to avoid clashing with the other algorithm of
the same name. Uses a 128KiB sliding window, with some minor improvement to the
algorithm.
.TP
\fB\-pm0\-\fR
Uncompressed (stored) data, as used by the PMarc tool.
.TP
\fB\-pm1\-\fR
Algorithm used by version 1 of the PMarc tool.
.TP
\fB\-pm2\-\fR
Algorithm used by version 2 of the PMarc tool.
.PP
.SH UNSUPPORTED FORMATS
The following formats are \fBnot\fR currently supported by Lhasa (but possibly
will be in the future):
.TP
\fB\-lh2\-\fR, \fB\-lh3\-\fR
These formats can be decompressed by LHa v2.0 but the tool could not actually
generate archives with these formats; they appear to have only been supported
in beta versions before the v2.0 release. As a result, few if any examples
exist in the wild.
.TP
\fB\-lh8\-\fR, \fB\-lh9\-\fR, \fB\-lha\-\fR, \fB\-lhb\-\fR, \fB\-lhc\-\fR, \fB\-lhe\-\fR
Extensions of the \-lh4\- format to even larger window sizes.
.TP
\fB\-pc1\-\fR
Format generated by the PopCom! compression utility for CP/M.
.PP
If you encounter examples of these in the wild, please get in touch.
.SH EXAMPLES
Here are some examples for how to invoke the program:
.TP
lha -v foobar.lzs
List the contents of the file \fBfoobar.lzs\fR (producing verbose output).
.TP
lha -xf foobar.exe
Extract the contents of a self-extracting archive file named \fBfoobar.exe\fR
to the current directory, overwriting existing files with the same names if
they exist.
.TP
lha -xqw=/tmp foobar.lzh
Extract the contents of \fBfoobar.lzh\fR to \fB/tmp\fR, overwriting any
existing files found there, and suppressing normal output (similar to
how other Unix tools such as \fBcp\fR(1) or \fBtar\fR(1) act silently
by default).
.SH SEE ALSO
\fBunzip\fR(1), \fBtar\fR(1), \fBgzip\fR(1), \fBbzip2\fR(1),
\fBxz\fR(1), \fBlzip\fR(1)
.SH HISTORY
The .lzh format originated with Kazuhiko Miki's MS\-DOS archive tool,
LArc, using the LZSS algorithm developed by Haruhiko Okumura, and
the .lzs filename extension. The container format was reused for
LHarc, by Haruyasu Yoshizaki (Yoshi), which used a new algorithm
named LZHUF and the .lzh extension. In later versions, LHarc was
renamed to LHA and extended with more effective compression algorithms.
.PP
Versions of the LHA tool were later ported to various different
operating systems, including the Amiga, Atari, MacOS, OS/2 and Unix.
A tool for MSX\-DOS named PMarc reused the container format with a new
compression algorithm (.pma extension).
.PP
The Unix version of the tool was developed by Masaru Oki, Nobutaka
Watazaki and Tsugio Okamoto, but was released under a software
license that does not conform to the Free Software or Open Source
Definitions. Lhasa was developed as a drop\-in replacement that is
Free Software and Open Source.
.SH BUGS
The current version does not allow the creation of new archive files.
.PP
Some obscure compression algorithms are not currently supported (see the
UNSUPPORTED FORMATS section above).
.PP
The tool does not currently do text format conversion for non-ASCII
filenames when listing the contents of archives. Non-ASCII characters
are replaced by a question mark.
.SH AUTHOR
Lhasa was written and is maintained by Simon Howard.
.SH COPYRIGHT
Copyright \(co 2011, 2012 Simon Howard.
.PP
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
.PP
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
